
<%@page import="com.shsh.safemanage.util.Util"%>
<%@page import="com.shsh.safemanage.model.WeakProblem"%>
<%@page import="com.shsh.safemanage.model.WeakUserReport"%>
<%@page import="com.shsh.safemanage.model.WeakReport"%>
<%@page import="com.shsh.safemanage.model.Problem"%>
<%@page import="com.shsh.safemanage.dao.ProblemDao"%>
<%@page import="com.shsh.safemanage.dao.DaoCreator"%>
<%@page import="com.shsh.safemanage.dao.WeakDao"%>
<%@page import="com.shsh.safemanage.util.RequestUtil"%>
<%@page import="com.shsh.safemanage.util.Constants"%>
<%@ page language="java" pageEncoding="UTF-8"%>
<%
{

session.removeAttribute(Constants.SESSION_WEAK_REPORT);

Long problemID = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_ID, (Long)null);
Long transferID = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_TRANSFER_ID, (Long)null);

WeakDao weakDao = DaoCreator.createWeakDao();
ProblemDao problemDao = DaoCreator.createProblemDao();


Problem problem = problemDao.getProblemByID(problemID);
WeakReport weakReport = weakDao.getWeakReportByProblemID(problemID);

session.setAttribute(Constants.SESSION_WEAK_REPORT, weakReport);

String fromPage = request.getParameter(Constants.REQUEST_PARAMETER_FROM_PAGE);
if(fromPage == null){
	fromPage = "user_info.jsp";
} else if(fromPage.equals("problemsTobeProcessed")){
	fromPage = "problems_tobe_processed.jsp";
} else if (fromPage.equals("yiban")) {
	fromPage = "problem_browse.jsp";
} else {
	fromPage = "user_info.jsp";
}
%>
<div class="hider" id="hider">
	<span>&nbsp;</span>
</div>
<div class="position">
	<img src="images/position2.jpg" style="padding: 7px 9px; float: left;" />当前位置：上海高桥分公司问题管理平台 &gt;&gt; 十大薄弱环节汇总 &gt;&gt;填报
</div>
<div class="tt"><%=problem.getProblemTitle() %></div>
<div class="content" style="">

<%
if(weakReport == null) {
%>
<div class="content" style="">
	<div style="float:left;padding-left:45%;padding-top:80px;font-size:14px;font-weight:bold;font-family:'微软雅黑','宋体';">未填报</div>
</div>
<%
return;
}
%>
<div class="apptab" id="problemBrowseListTD">
<%
if(weakReport.getReportType()!=Constants.WEAK_REPORT_TYPE_DANWEI) {
%>
<%@include file="/weak/feedback_report_notdanwei_section.jsp" %>
<%
} else {
%>
<%@include file="/weak/feedback_report_danwei_section.jsp" %>
<%
}
%>
</div>


</div>
<script type="text/javascript">
function checkWeakType(problemID, weakType){
	var checkedID = '#weakType' + problemID + '_' + weakType;
	var isChecked = $(checkedID).attr('checked');
	var valueID = 'noneWorkTimeValue'+problemID;
	var noneWorkTime = getElementValueByID(valueID);
	
	var checkID0 = '#weakType' + problemID + '_' + 0;
	var checkID1 = '#weakType' + problemID + '_' + 1;
	var checkID2 = '#weakType' + problemID + '_' + 2;
	$(checkID0).attr('checked', false);
	$(checkID1).attr('checked', false);
	$(checkID2).attr('checked', false);
	
	if(isChecked != true){
		weakType = 2;
	}
	loadPageSection('<%=request.getContextPath()%>/weak/refresh_feedback_report_process.jsp', 'problemBrowseListTD', 
			{
				problemID : problemID,
				weakType: weakType,
				noneWorkTime: noneWorkTime
			},
			true
		);
}

function checkDelete(problemID){
	var checkedID = '#delete' + problemID;
	var reverseID = '#reverse' + problemID;
	var valueID = 'noneWorkTimeValue'+problemID;
	var noneWorkTime = getElementValueByID(valueID);
	
	$(reverseID).attr('checked', false);
	
	var needDelete = $(checkedID).attr('checked');
	loadPageSection('<%=request.getContextPath()%>/weak/refresh_feedback_report_process.jsp', 'problemBrowseListTD', 
			{
				problemID : problemID,
				needDelete: needDelete,
				noneWorkTime: noneWorkTime
			},
			true
		);
}

function checkReverse(problemID){
	var checkedID = '#delete' + problemID;
	var reverseID = '#reverse' + problemID;
	var valueID = 'noneWorkTimeValue'+problemID;
	var noneWorkTime = getElementValueByID(valueID);
	
	$(checkedID).attr('checked', false);
	
	var needDelete = $(checkedID).attr('checked');
	loadPageSection('<%=request.getContextPath()%>/weak/refresh_feedback_report_process.jsp', 'problemBrowseListTD', 
			{
				problemID : problemID,
				needDelete: needDelete,
				noneWorkTime: noneWorkTime
			},
			true
		);	
}

function checkNoneWorkTime(problemID){
	var checkedID = '#noneWorkTimeCheck' + problemID;
	var valueID = 'noneWorkTimeValue'+problemID;
	var hasNoneWorkTime = $(checkedID).attr('checked');
	var noneWorkTime = getElementValueByID(valueID);
	loadPageSection('<%=request.getContextPath()%>/weak/refresh_feedback_report_process.jsp', 'problemBrowseListTD', 
			{
				problemID : problemID,
				hasNoneWorkTime: hasNoneWorkTime,
				noneWorkTime: noneWorkTime
			},
			true
		);
}

function createWeakParamJSON(){
	var paramJSON = '';	
	$('input:text').each(function(){
		if(this.name!=null && this.name!='') {
			var paramName = "'" + this.name + "'" ;
			var paramValue =  "'" + $(this).attr('value') + "'";
			paramJSON =  paramJSON + "," + paramName + ":" + paramValue;
		}
	});
	
	paramJSON = paramJSON.substring(1);
	paramJSON = '{' + paramJSON + '}';

	return paramJSON;
}

function feedbackWeakReport(){
	var paramJSON = createWeakParamJSON();
	
	var processMethod = 0;
	var processRadio1 = document.getElementById('processRadio1');
	var processRadio3 = document.getElementById('processRadio3');
	if (processRadio3 != null && processRadio3.checked) {
		processMethod = 3;
	} else 	if (processRadio1 != null && processRadio1.checked) {
		processMethod = 1;
	}

	var weakReportType = getElementValueByID('weakReportType');
	var problemTitle = '';
	if(weakReportType == 1){
		problemTitle = '《一线员工积分台账》';
	} else if(weakReportType == 2){
		problemTitle = '《管理人员积分台帐》';	
	} else if(weakReportType == 3){
		problemTitle = '《单位积分台帐》';	
	}
	
	if ($.dialog.confirm('您确定提交此报告吗？', function(){
		openWaitingDialog('waitingDialog');
		$.ajax({
			type:'post',
			url:'<%=request.getContextPath()%>/weak/feedback_report_process.jsp',
			data:{
				paramJSON: paramJSON,
				processMethod: processMethod,
				id: <%=problemID%>,
				transferID: <%=transferID%>,
				feedback: '',
				problemTitle: problemTitle
			},
			success:function(data,state,xmlhttp){
				var obj = null;
				try {
					obj = eval('(' + data + ')');
				} catch (e) {
				}
				if (typeof(obj.isSuccess) != 'undefined') {
					closeWaitingDialog('waitingDialog');
					if (obj.isSuccess == 'true') {
						$.dialog('报告填报成功！', function() { loadPageSection('<%=request.getContextPath()%>/user_infor.jsp', 'mainContentDiv'); });
					} else {
						$.dialog.alert(obj.error);
					}
				}
			}
		});
	}, function(){}));
}

function cancelFeedback(){
	if ($.dialog.confirm('您确定取消反馈吗？', function(){
		loadPageSection('<%=request.getContextPath()%>/<%=fromPage%>', 'mainContentDiv');
	}, function(){}));	
}
</script>
<%
}
%>